using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertConfiguration(string name, string description, bool isDefault)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationInsert", name, description, isDefault)));
		}

        public int UpdateConfiguration(Guid configurationId, string name, string description, bool isDefault)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationUpdate", GetNull(configurationId), name, description, isDefault));
		}

        public int DeleteConfiguration(Guid configurationId) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationDelete", configurationId));
		}

        public DataRow SelectConfiguration(Guid configurationId) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSelect", configurationId);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectConfigurations() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSelectAll").Tables[0];
        }

    }

}
